package com.junit;

import com.dao.impl.UserDaoImpl;
import com.pojo.User;
import org.junit.Test;
import com.service.impl.userServiceImpl;
public class UserDaoTest {
    /**
     * 注册测试
     */
    @Test
    public void test2(){
        userServiceImpl userImp = new userServiceImpl();
        userImp.register(new User("root","root",""));
    }

    /**
     * 登录测试
     */
    @Test
    public void test3(){
        userServiceImpl userImp = new userServiceImpl();
        User user = userImp.logUser(new User("root","root",""));
        System.out.println(user);
    }
    /**
     * 验证测试
     */
    @Test
    public void test4(){
        userServiceImpl userImp = new userServiceImpl();
       boolean b =  userImp.existsUserName("root11");
        if(b){
            System.out.println("用户名存在");
        }else {
            System.out.println("用户名可用");
        }
    }
    @Test
    public void test(){
        UserDaoImpl base = new UserDaoImpl();
        User user = base.QueryUserByUsernameAndPassword("root","root");
        if(user==null){
            System.out.println("用户名密码错误");
        }else {
            System.out.println("登陆成功");
        }
        System.out.println(user);
        User user1 = base.QueryUserByUsername("root");
        if(user1==null){
            System.out.println("可以注册");
        }else {
            System.out.println("用户名已存在请重新输入");
        } System.out.println(user1);
        User user2 = new User("王五","11111","qq@cxom");
        int i=base.SaveUser(user2);
        if(i==1){
            System.out.println("注册成功");
        }else {
            System.out.println("注册失败");
        }
    }
}
